import pygame
import random
import string

# 颜色常量
WHITE = (255, 255, 255)
BLACK = (0, 0, 0)
RED = (255, 0, 0)
GREEN = (0, 255, 0)
BLUE = (0, 0, 255)
GRAY = (200, 200, 200)
LIGHT_GRAY = (240, 240, 240)
DARK_GRAY = (100, 100, 100)

# 屏幕尺寸常量
SCREEN_WIDTH = 1024
SCREEN_HEIGHT = 768

# 球员姓名列表（示例）
FIRST_NAMES = ["张", "王", "李", "赵", "刘", "陈", "杨", "黄", "周", "吴", "徐", "孙", "胡", "朱", "高"]
LAST_NAMES = ["强", "伟", "军", "勇", "杰", "涛", "磊", "超", "明", "刚", "辉", "飞", "阳", "宇", "浩"]

# 球员简介模板
PLAYER_BIO_TEMPLATES = [
    "{name}，{age}岁，司职{position}，擅长{skill}",
    "来自{hometown}的{position}，{age}岁，以{skill}著称",
    "{age}岁的{position}球员，曾效力于{previous_team}",
    "{name}是一名{position}，{age}岁，拥有出色的{skill}"
]

# 位置列表
POSITIONS = ["前锋", "中场", "后卫", "守门员"]

# 技能列表
SKILLS = ["射门", "传球", "防守", "速度", "头球", "技术", "意识", "耐力"]

#  hometown列表
HOMETOWNS = ["北京", "上海", "广州", "深圳", "杭州", "成都", "武汉", "重庆", "西安", "青岛"]

# 之前球队列表
PREVIOUS_TEAMS = ["北京队", "上海队", "广州队", "深圳队", "杭州队", "成都队", "武汉队", "重庆队", "西安队", "青岛队"]

# 生成随机球员姓名
def generate_player_name():
    return random.choice(FIRST_NAMES) + random.choice(LAST_NAMES)

# 生成球员简介
def generate_player_bio(name):
    age = random.randint(18, 35)
    position = random.choice(POSITIONS)
    skill = random.choice(SKILLS)
    hometown = random.choice(HOMETOWNS)
    previous_team = random.choice(PREVIOUS_TEAMS)
    template = random.choice(PLAYER_BIO_TEMPLATES)
    return template.format(name=name, age=age, position=position, skill=skill, hometown=hometown, previous_team=previous_team)

# 初始化字体
def init_fonts():
    pygame.font.init()
    # 尝试加载中文字体
    try:
        font = pygame.font.Font("SimHei.ttf", 24)
        small_font = pygame.font.Font("SimHei.ttf", 18)
        large_font = pygame.font.Font("SimHei.ttf", 36)
    except:
        # 如果无法加载中文字体，使用默认字体
        font = pygame.font.Font(pygame.font.get_default_font(), 24)
        small_font = pygame.font.Font(pygame.font.get_default_font(), 18)
        large_font = pygame.font.Font(pygame.font.get_default_font(), 36)
    return font, small_font, large_font

# 检查阶段条件是否完成
def check_stage_conditions(game):
    if game.stage == 1:
        # 第一阶段条件：连续两个赛季排名前三
        return  game.consecutive_top_three >= 2
    elif game.stage == 2:
        # 第二阶段条件：排名第一
        return game.get_ranking()[0] == game.user_team
    return False

# 检查特殊事件
def check_special_events(game):
    # 这里可以实现各种特殊事件的触发逻辑
    pass